<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创建数组</title>
    <script>
        // 创建数组的两种方法
        let arr = [1, 2, 4];
        console.log(arr[0]);

        let arr2 = new Array();
        console.log(arr2);
        arr2[0] = 1;
        arr2[8] = 9;
        console.log(arr2);
        console.log(arr2[2]); // undefined

console.log('-----------------------------------------------------');
        // Array 有很大的缺陷
        console.log(new Array(5)); // 
        // console.log(new Array(2.5)); // 
        console.log(new Array(3, 2, 2.5, {'name': 'abc'})); // 
        console.log(new Array('abc')); // ['abc']
        console.log('=============================================');
        // 判断是否是数组对象
        console.log(arr instanceof Array);
        let obj = {}; // new Object()
        console.log(obj instanceof Object); // false
        console.log(Array.isArray(arr)); // true
        console.log(Array.isArray(obj)); // false
    </script>
</head>
<body>
    
</body>
</html>